home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter_lib / Library / samples / pawn.c < prev    next >
C/C++ Source or Header  |  1999-12-03  |  3KB  |  94 lines

  1. /*
  2. **      $VER: pawn.c 1.00 (20.3.1999)
  3. **
  4. **      Creation date     : 20.3.1999
  5. **
  6. **      Description       :
  7. **         MeshWriter testprogram shape module.
  8. **
  9. **
  10. **      Written by Stephan Bielmann
  11. **
  12. */
  13.  
  14. /*************************** Includes *******************************/
  15.  
  16. #include <meshwriter/meshwriter.h>
  17. #include <pragma/meshwriter_lib.h>
  18.  
  19. /**************************** Defines *******************************/
  20.  
  21. #define PI            3.14159265359
  22. #define ROTSTEPS      9
  23.  
  24. /*********************** Type definitions ***************************/
  25.  
  26. /********************** Private functions ***************************/
  27.  
  28. /********************** Public functions ****************************/
  29.  
  30. /********************************************************************\
  31. *                                                                    *
  32. * Name         : pawn                                                *
  33. *                                                                    *
  34. * Description  : Draws a pawn with the help of the rotation function.*
  35. *                                                                    *
  36. * Arguments    : mesh    IN  : An initialized mesh handle.           *
  37. *                                                                    *
  38. * Comment      :                                                     *
  39. *                                                                    *
  40. \********************************************************************/
  41. void pawn(ULONG mesh) {
  42.   TOCLVertex v1,v2,vr;
  43.   TOCLColor color;
  44.   ULONG white,i;
  45.   TOCLFloat apawn[] = {40,40,39,37,38.5,39,38,37,36,34.5,31,28,26,23.6,22,20,18,16,14.5,
  46.                        13,11.5,11.2,11.2,11.5,13.6,15.5,22,28.7,28.5,22,16,16.8,20,22.7,
  47.                        24.5,25.3,25.5,25,24,22,18.5,13.5,0};
  48.  
  49.   MWLMeshMaterialAdd(mesh,&white);
  50.   color.r=255,color.g=255,color.b=255;
  51.   MWLMeshMaterialNameSet(mesh,white,"White");
  52.   MWLMeshMaterialDiffuseColorSet(mesh,white,&color);
  53.   MWLMeshMaterialShininessSet(mesh,white,0);
  54.   MWLMeshMaterialTransparencySet(mesh,white,0);
  55.  
  56.   MWLMeshNameSet(mesh,"Pawn");
  57.  
  58.   // the ground, a circle
  59.   v1.x=40,v1.y=0,v1.z=0;
  60.   vr.x=0,vr.y=0;
  61.   MWLMeshPolygonAdd(mesh,white);
  62.   for(vr.z=0;vr.z<2*PI;vr.z+=PI/ROTSTEPS) {
  63.     MWLMeshPolygonVertexAdd(mesh,&v1);
  64.     MWLMeshRotationChange(mesh,&vr,CTMSET);
  65.   }
  66.  
  67.   // the body, with the help of the apawn radius array
  68.   v1.y=0;
  69.   v2.y=0;
  70.   vr.x=0,vr.y=0;
  71.   for(i=0;i<43-1;i++) {
  72.     MWLMeshPolygonAdd(mesh,white);
  73.     v2.x=apawn[i+1],v2.z=2*(i+1);
  74.     MWLMeshPolygonVertexAdd(mesh,&v2);
  75.     v1.x=apawn[i],v1.z=(2*i);
  76.     MWLMeshPolygonVertexAdd(mesh,&v1);
  77.  
  78.     for(vr.z=0;vr.z<2*PI;vr.z+=PI/ROTSTEPS) {
  79.       MWLMeshRotationChange(mesh,&vr,CTMSET);
  80.  
  81.       v1.x=apawn[i],v1.z=2*i;
  82.       MWLMeshPolygonVertexAdd(mesh,&v1);
  83.       v2.x=apawn[i+1],v2.z=2*(i+1);
  84.       MWLMeshPolygonVertexAdd(mesh,&v2);
  85.  
  86.       MWLMeshPolygonAdd(mesh,white);
  87.       MWLMeshPolygonVertexAdd(mesh,&v2);
  88.       MWLMeshPolygonVertexAdd(mesh,&v1);
  89.     }
  90.   }
  91. }
  92.  
  93. /************************* End of file ******************************/
  94.